package com.teamwork.module03.controller;

import com.teamwork.module03.mapper.MenuMapper;
import com.teamwork.module03.pojo.Menu;
import com.teamwork.common.result.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/menu")
public class MenuController {
    @Resource
    private MenuMapper menuMapper;

    @GetMapping
    public Result getMenuByUserid(Long userid){

        List<Menu> menus = menuMapper.getByUserId(userid);

        if(menus.size()==0){

            return Result.failure("没有该用户id");

        }
        return  Result.success(menus);
    }



}
